﻿@namespace Bit.BlazorUI
@inherits BitComponentBase

<div @ref="RootElement" @attributes="HtmlAttributes"
     id="@_Id"
     role="toolbar"
     aria-label="@AriaLabel"
     style="@StyleBuilder.Value"
     class="@ClassBuilder.Value"
     dir="@Dir?.ToString().ToLower()">

    <CascadingValue Value="this" IsFixed="true">
        <div style="@Styles?.Header" class="bit-pvt-hct @Classes?.Header" role="tablist">
            @ChildContent
        </div>
    </CascadingValue>

    @if (HeaderOnly is false)
    {
        if (MountAll)
        {
            @foreach (var item in _allItems)
            {
                <div role="tabpanel"
                     aria-hidden="false"
                     aria-labelledby="@(item?._Id)"
                     style="@GetItemStyle(item)"
                     class="bit-pvt-cct @GetItemClass(item)">
                    @(item?.Body ?? item?.ChildContent)
                </div>
            }
        }
        else
        {
            <div role="tabpanel"
                 aria-hidden="false"
                 aria-labelledby="@(_selectedItem?._Id)"
                 style="@GetItemStyle(_selectedItem)"
                 class="bit-pvt-cct @GetItemClass(_selectedItem)">
                @(_selectedItem?.Body ?? _selectedItem?.ChildContent)
            </div>
        }
    }
</div>